import Vue from 'vue'
import Router from 'vue-router'

import index from '@/pages/index'
import login from '@/pages/login'


import my_share_month from '@/pages/my_share_month'
import my_share_team from '@/pages/my_share_team'
import income from '@/pages/income'
import my_share_huiyuanma from '@/pages/my_share_huiyuanma'
import fuwushangma from '@/pages/fuwushangma'
import my_share_tuijianren from '@/pages/my_share_tuijianren'
import my_share_income from '@/pages/my_share_income'
import author from '@/pages/author'
import my_share_monthly_earnings from '@/pages/my_share_monthly_earnings'

import received from '@/pages/received'


Vue.use(Router)
export default new Router({
  mode: 'history',
  // base: '/wuwushop/',
  // mode: 'hash',
  routes: [
    {
      //每月收益明细
      path: '/my_share_monthly_earnings',
      name: 'my_share_monthly_earnings',
      component: my_share_monthly_earnings,
      meta: {
        isShow: true
      }
    },
    // 我的分享-收益明细
    {
      // path:'/my_share_month',
      path:'/my_share_income',
      name:'my_share_income',
      component:my_share_income,
      meta: {
        isShow: true
      }
    },
    // 我的分享-我的推荐人
    {
      path:'/my_share_tuijianren',
      // path:'/',
      name:'my_share_tuijianren',
      component:my_share_tuijianren,
      meta: {
        isShow: true
      }
    },
    // 我的分享-服务商码
    {
      path:'/fuwushangma',
      // path:'/',
      name:'fuwushangma',
      component:fuwushangma,
      meta: {
        isShow: true
      }
    },
    // 我的分享-会员码
    {
      path:'/my_share_huiyuanma',
      // path:'/',
      name:'my_share_huiyuanma',
      component:my_share_huiyuanma,
      meta: {
        isShow: true
      }
    },
    // 我的分享-收益明细（上划效果）
    {
      path:'/income',
      // path:'/',
      name:'income',
      component:income,
      meta: {
        isShow: true
      }
    },
    // 我的分享-我的团队
    {
      path:'/my_share_team',
      // path:'/',
      name:'my_share_team',
      component:my_share_team,
      meta: {
        isShow: true
      }
    },
    // 我的分享-每月收益明细
    {
      path:'/my_share_month',
      // path:'/',
      name:'my_share_month',
      component:my_share_month,
      meta: {
        isShow: true
      }
    },
    //首页
    {
      path: '/distribution',
      name: 'index',
      component: index,
      meta: {
        isShow: true
      }
    },
    //login
    {
      path: '/login',
      name: 'login',
      component: login,
      meta: {
        isShow: true
      }
    },
    //收到分享
    {
      path: '/received',
      name: 'received',
      component: received,
      meta: {
        isShow: true
      }
    },
    {
      path: '/author',
      name: 'author',
      component: author,
    },

    
    
    


  ],
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return {
        x: 0,
        y: 0
      }
    }
    if (to.hash) {
      return {
        selector: to.hash
      }
    }
  },

  beforeRouteEnter(to, from, next) {
    // 这个地方的代码是在create之前调用
    next(vm => {
      if (to.meta.isShow > from.meta.index) { } else if (to.meta.index < from.meta.index) { } else { }
    })

  },
})





